﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 8/29/2009
 * Time: 12:58 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Buaya.Model;

namespace Buaya.Gui
{
	/// <summary>
	/// Description of PagIbigPremiumForm.
	/// </summary>
	public partial class PagIbigPremiumForm : BaseForm
	{
		public PagIbigPremiumForm() : this(new PagIbigPremium())
		{
			
		}
		
		public PagIbigPremiumForm(PagIbigPremium p)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Model = p;
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			PagIbigPremium p = Model as PagIbigPremium;
			textBoxBracketCode.Text = p.Code;
			textBoxDescription.Text = p.Description;
			textBoxPS.Text = p.PS.ToString("0.00");
			textBoxES.Text = p.ES.ToString("0.00");
			textBoxContribution.Text = p.Contribution.ToString("0.00");
			checkBoxInactive.Checked = p.Inactive;
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			PagIbigPremium p = Model as PagIbigPremium;
			p.Code = textBoxBracketCode.Text;
			p.Description = textBoxDescription.Text;
			p.PS = Util.ConvertUtility.ToDouble(textBoxPS.Text);
			p.ES = Util.ConvertUtility.ToDouble(textBoxES.Text);
			p.Contribution = Util.ConvertUtility.ToDouble(textBoxContribution.Text);
			p.Inactive = checkBoxInactive.Checked;
			SessionFacade.SaveOrUpdatePagIbigPremium(p);
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
